The installer will copy all the necessary files into the product's installation folder (usually in [Installation Folder]\Xceed\Xceed DataGrid for WPF v[VERSION]) as well as place a copy of the Xceed DataGrid for WPF assemblies (Xceed.Wpf.DataGrid.dll) in the global assembly cache.
In order to begin using Xceed DataGrid for WPF, its assemblies must be referenced in your project using the following steps:
1. Select the "Add Reference..." option from the "Project" menu to open the "Add Reference" dialog box.
2. Select the ".NET" tab, browse to the "Xceed DataGrid for WPF" assembly and select it. To use the Office 2007 themes, the corresponding assembly must also be included.
3. Press "OK" to add the assemblies to your project's references.
Once the assemblies have been added to your project, the namespace maps that are to be used must be declared. In XAML this is done using the xmlns attribute. If the DataGridControl control has been added to a design surface, the xmlns attribute is automatically added.
XAML | Copy Code |
---|---|
xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid" |
Namespace | Description |
---|---|
Xceed.Wpf.DataGrid | The Xceed.Wpf.DataGrid namespace regroups all the classes that are required by the DataGridControl class to edit and display data. |
Xceed.Wpf.DataGrid.Converters | The Xceed.Wpf.DataGrid.Converters namespace regroups all the converter classes. |
Xceed.Wpf.DataGrid.Markup | The Xceed.Wpf.DataGrid.Markup namespace regroups the XAML-specific classes. |
Xceed.Wpf.DataGrid.ValidationRules | The Xceed.Wpf.DataGrid.ValidationRules namespace regroups all the validation rule classes. |
Xceed.Wpf.DataGrid.Views | The Xceed.Wpf.DataGrid.Views namespace regroups all the classes which are required to apply views and themes to a DataGridControl. |
Xceed.Wpf.DataGrid.Settings | The Xceed.Wpf.DataGrid.Settings namespace regroups all the classes, enumerations, and structures required to persist the settings of a grid and its elements. |
Xceed.Wpf.DataGrid.Automation | The Xceed.Wpf.DataGrid.Automation namespace contains all the classes that are required to support UI automation. |
In C# or VB.NET, the using and Imports directives can be used to create aliases for the namespaces listed in Table 1. If Xceed DataGrid for WPF is being used in either of these development languages the Xceed.Wpf.DataGrid.Markup namespace can be omitted as it contains XAML-specific classes.
VB.NET | Copy Code |
---|---|
Imports Xceed.Wpf.DataGrid |
C# | Copy Code |
---|---|
|
The last step is to add a grid to your page or window. The examples found throughout the documentation usually place the grid inside a Grid, as demonstrated in the following example.
This first code example demonstrates how to create a connection to the Access version of the Northwind database and create a property named "Orders" to which the grid will be bound. The code should be placed in the App.xaml.cs file.
VB.NET |
Copy Code |
---|---|
Public Partial Class App Inherits Application Public Property Data As DataSet Public Property Orders As DataTable Protected Overrides Sub OnStartup(ByVal e As StartupEventArgs) ' Set the licence key Xceed.Wpf.DataGrid.Licenser.LicenseKey = "Enter your license key here" Data = Xceed.Wpf.DataGrid.Samples.SampleData.DataProvider.GetNorthwindDataSet() Orders = Data.Tables("Orders") MyBase.OnStartup(e) End Sub End Class |
C# |
Copy Code |
---|---|
public partial class App : Application { public DataSet Data { get; set; } public DataTable Orders { get; set; } protected override void OnStartup( StartupEventArgs e ) { // Set the licence key Xceed.Wpf.DataGrid.Licenser.LicenseKey = "Enter your license key here"; Data = Xceed.Wpf.DataGrid.Samples.SampleData.DataProvider.GetNorthwindDataSet(); Orders = Data.Tables[ "Orders" ]; base.OnStartup( e ); } } |
The next example demonstrates how to bind a grid to the Orders table, which is retrieved through the Orders property implemented in the code above.
XAML |
Copy Code |
---|---|
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid"> <Grid.Resources> <xcdg:DataGridCollectionViewSource x:Key="cvs_orders" Source="{Binding Source={x:Static Application.Current}, Path=Orders}"/> </Grid.Resources> <xcdg:DataGridControl x:Name="OrdersGrid" ItemsSource="{Binding Source={StaticResource cvs_orders}}"/> </Grid> |
By default, a grid will take all the room that it requires; therefore, if it is not given a size constraint, such as when it is placed in a StackPanel and a large amount of data items are present, UI virtualization will be lost—resulting in a significant loss in performance. To preserve UI virtualization when a grid is in a StackPanel, the MaxWidth and MaxHeight properties (or Width and Height) must be used to constrain the grid. As an alternative, a DockPanel or Grid can be used as both impose size constraints on their child elements.
The last step is to license Xceed DataGrid for WPF by setting the property. Refer to the Licensing topic for detailed information on how to license the component for distribution.